package adventure.commands;

import adventure.*;
import player.*;

/**
 *
 * @author Michael Hanns
 *
 */
public class SetSuppressTick extends AbstractCommand {

    public SetSuppressTick(Adventure a) {
        super(a, new String[]{"SUPPRESSTICK"});
    }

    @Override
    public String validateAndExecute(Player p, String[] args) {
        if (args.length == 2) {
            if (args[1].equalsIgnoreCase("on")) {
                p.setSuppressTick(true);
                return "Suppress tick set to ON.";
            } else if (args[1].equalsIgnoreCase("off")) {
                p.setSuppressTick(false);
                return "Suppress tick set to OFF.";
            }
            return "Please specify ON or OFF.\ne.g. suppresstick on";
        }

        String out = "Suppress tick set to ";

        if (p.suppressTick()) {
            out += "ON.\nTo stop suppressing >TICK< notifications, type suppresstick off.";
        } else {
            out += "OFF.\nTo suppress >TICK< notifications, type suppresstick on.";
        }
        return out;
    }
}
